package game;

public class GameMap {
	// The map as a matrix of integers.
	private int[][] map;
	
	/**
	 * Class constructor.
	 * @param map - map of the game
	 */
	public GameMap(int width, int height){
		int[][] map = new int[height][width];
		this.map = map;
	}
	
	/**
	 * Get the map.
	 * @return The current map.
	 */
	public int[][] getMap(){
		return this.map;
	}
	
	/**
	 * Get the map width.
	 * @return Map width.
	 */
	public int getWidth(){
		return this.map[0].length;
	}
	
	/**
	 * Get the map height.
	 * @return Map height.
	 */
	public int getHeight(){
		return this.map.length;
	}
	
	/**
	 * Set a new map.
	 * @param newMap 	The new map.
	 */
	public void setMap(int[][] newMap){
		this.map = newMap;
	}
	
	/**
	 * Sets a given point (number) on the map at the given (x,y)
	 * @param x 	The x coordinate
	 * @param y 	The y coordinate
	 * @param point The number to put at the given coordinates (usually 0 or 1)
	 */
	public void setPointOnMap(int x, int y, int point){
		if(x > 0 && x < getWidth() && y > 0 && y < getHeight()){
			map[x][y] = point;
		}
	}
	
	/**
	 * Checks if the map has a collision point at the given (x,y)
	 * @param x 	The x coordinate
	 * @param y 	The y coordinate
	 * @return Map has a collision point at (x,y) or not.
	 */
	public boolean hasPointAtLocation(int x, int y){
		if(map[y][x] == 1){
			return true;
		}
		return false;
	}
	
	/**
	 * Clear the map.
	 */
	public void clearMap(){
		int[][] clearMap = new int[getWidth()][getHeight()];
		this.setMap(clearMap);
	}
}
